home *** CD-ROM | disk | FTP | other *** search
- /* DISPLAY.C Generic Screen Library Functions */
-
- /* Copyright (c) Gregg Jennings 1989-1994
-
- Version 1.1 13-Jan-1994 Borland
- */
-
- #include <stdio.h>
- #include <ctype.h>
- #include <conio.h>
- #include <string.h>
- #include <dos.h>
-
- #include "mylib.h"
-
- void put(register unsigned int i,int c)
- {
- for (; i > 0; i--)
- conout(c);
- }
-
- void print(const char *s)
- {
- while (*s)
- send(*s++);
- }
-
- void printc(const char *s)
- {
- put((80-strlen(s))/2,' ');
- print(s);
- send('\n');
- }
-
- void bprint(const char *s)
- {
- byte r,c;
-
- getcursor(&r,&c);
- print(s);
- setcursor(r,c);
- }
-
- void cursor(int m)
- {
- static byte a,b;
-
- if (m)
- getcursor(&a,&b);
- else
- setcursor(a,b);
- }
-
- /*
- In-line asm - MSC and Borland formats.
-
- intdos() type REGS stuff can be used but they are very bulky.
- */
-
- #ifdef _MSC_VER
- #pragma optimize("gle",off)
- #endif
-
- void charout(int c)
- {
- _asm mov ax,c
- _asm mov ah,10
- _asm xor bx,bx
- _asm mov cx,1
- _asm int 10h
- }
-
- void conout(int _c)
- {
- _asm mov ax,_c
- _asm mov ah,0Eh
- _asm mov bx,0
- _asm int 10h
- }
-
- void conouta(int _c, int _a)
- {
- _asm mov ax,_c
- _asm mov ah,09h
- _asm mov bx,_a
- _asm mov bh,0
- _asm mov cx,1
- _asm int 10h
- }
-
- int conin(void)
- {
- _asm xor ax,ax
- _asm int 16h
- }
-
- int conflag(void)
- {
- _asm mov ah,2
- _asm int 16h
- }
-
- int input(void)
- {
- _asm mov ah,7
- _asm int 21h
- _asm xor ah,ah
- }
-
- #define TABSTOP 8
-
- int send(int c)
- {
- register int i;
- register int r;
-
- r=0;
- if (c=='\n')
- conout('\r');
- if (c=='\t') /* Check for tab and to simulate or not */
- {
- char _t;
- _asm mov ah,3
- _asm mov bh,0
- _asm int 10h
- _asm mov _t,dl
- for (i=0;i<(TABSTOP-(_t%TABSTOP));i++)
- conout(' ');
- }
- else
- {
- conout(c);
- ++r;
- }
- return(r);
- }
-
- void cursoron(void)
- {
- _asm mov al,1
- _asm mov ch,11
- _asm mov cl,12
- _asm int 10h
- }
-
- void cursoroff(void)
- {
- _asm mov al,1
- _asm mov ch,20
- _asm mov cl,0
- _asm int 10h
- }
-
- #ifndef __BORLANDC__
-
- void clreol(void)
- {
- _asm mov ah,0Ah
- _asm mov al,' '
- _asm xor bh,bh
- _asm mov cx,79
- _asm int 10h
- }
-
- #endif
-
- void getcursor(byte *r, byte *c)
- {
- byte a,b;
-
- _asm mov ah,3
- _asm xor bh,bh
- _asm int 10h
- _asm mov a,dh
- _asm mov b,dl
- *r=a;
- *c=b;
- }
-
- void setcursor(byte r, byte c)
- {
- _asm mov ah,2
- _asm xor bh,bh
- _asm mov dh,r
- _asm mov dl,c
- _asm int 10h
- }
-
- void curright(void)
- {
- _asm mov ah,3
- _asm xor bh,bh
- _asm int 10h
- _asm inc dl
- _asm mov ah,2
- _asm xor bh,bh
- _asm int 10h
- }
-
- void curleft(void)
- {
- _asm mov ah,3
- _asm xor bh,bh
- _asm int 10h
- _asm dec dl
- _asm mov ah,2
- _asm xor bh,bh
- _asm int 10h
- }
-